package com.mango.iot.gateway.coap.common;

import java.util.EnumSet;

/**
 * <pre>
 * 状态返回码
 * </pre>
 *
 * @author liangfeihu
 * @number 53669
 * @since 2021/4/27 下午2:34
 */
public enum ResultCode {

    SUCCESS("0000", "成功"),

    INVALID_PARAMETER("0001", "参数错误"),

    SERVER_ERROR("9999", "系统错误"),

    DEVICE_NOT_FOUND("1000", "设备不存在"),

    PRODUCT_NOT_FOUND("1001", "产品不存在"),

    DEVICE_DISABLE("1002", "设备被禁用"),

    DEVICE_AUTH_NOT_SUPPORT("1002","认证不支持");

    ResultCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    private String code;
    private String message;

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    private static final EnumSet<ResultCode> RESULT_CODES = EnumSet.allOf(ResultCode.class);

    public static final ResultCode getResultCode(String code) {
        for (ResultCode resultCode : RESULT_CODES) {
            if (resultCode.getCode().equals(code)) {
                return resultCode;
            }
        }
        return null;
    }

}
